/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * only version 2 as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * Description:
 * Author: huawei
 * Create: 2019-10-15
 */
#ifndef SVM_MASTER_PROC_MNG_H
#define SVM_MASTER_PROC_MNG_H

#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/rbtree.h>

#include "svm_res_idr.h"
#include "svm_task_dev_res_mng.h"

struct devmm_proc_async_copy_record {
    struct svm_idr task_idr;
    atomic_t task_cnt;
};

#define DEVMM_CONVERT_TREE_NUM   128ul
struct devmm_convert_dma {
    struct rb_root dma_rbtree;
    spinlock_t rbtree_lock;
};

struct devmm_dma_desc_node_rb_info {
    struct rb_root root;
    spinlock_t spinlock;
};

struct devmm_svm_proc_master {
    struct devmm_task_dev_res_info task_dev_res_info;

    struct devmm_proc_async_copy_record async_copy_record;
    struct devmm_convert_dma convert_dma[DEVMM_CONVERT_TREE_NUM];

    struct devmm_dma_desc_node_rb_info dma_desc_rb_info;
};

#endif /* SVM_MASTER_PROC_MNG_H */

